package com.action;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bean.ResponseBean;
import com.service.JifenChongzhiService;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Auther: tz
 * @Date: 2023/11/29 16:26
 */
@CrossOrigin
@RestController
@RequestMapping("/jifenChongzhi")
public class JifenChongzhiAction {

    @Autowired
    private JifenChongzhiService jifenChongzhiService;

    /**
     * 分页查询积分充值记录
     * @param page
     * @param limit
     * @param key
     * @param startTime
     * @param endTime
     * @return
     */
    @RequestMapping("/getJifenChongzhiByPage")
    public ResponseBean getJifenChongzhiByPage(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit, String key,
                                               @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime){
        if(StringUtil.isNull(startTime)){
            startTime=null;
        }
        if(StringUtil.isNull(endTime)){
            endTime=null;
        }
        IPage iPage = jifenChongzhiService.getJifenChongzhiByPage(page,limit,key,startTime,endTime);
        return new ResponseBean(0,iPage.getTotal(),"查询成功",iPage.getRecords());
    }
}
